function subsetsWithDup(nums) {
    function backtracking(startIndex, temp) {
        res.push([...temp])
        for (let i = startIndex; i < nums.length; i ++) {
            if (i > startIndex && nums[i] === nums[i - 1]) continue
            temp.push(nums[i])
            backtracking(i + 1, temp)
            temp.pop()
        }
    }
    let res = []
    nums.sort((a,b) => a - b)
    backtracking(0,[])
    return res
}
// let arr = subsetsWithDup([1,2,3,20,28])
let arr = subsetsWithDup([1,2,4,12])
let m = 0
for (let i = 1; i < arr.length; i++) {
    let value = arr[i].reduce((a,b) => a & b)
    for (let j = 1; j < Math.floor(Math.log2(value));j++) {
        if (Math.floor(value / (Math.pow(2,j))) === (value / (Math.pow(2,j)))) {
            if (m < j) {
                m = j
            }
        }
    }
}
console.log(m)
